﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<ThietBiSo.LinQDB.DichVu>" %>

<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Website - bảng điều khiển
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  <script type="text/javascript">

      function DichVu_Delete(ma) {
        var cnf = window.confirm("Bạn chắc chắn xóa?");
        if (cnf) {
            $.ajax({
                type: "POST",
                url: '<%=Url.Action("Delete") %>',
                cache: false,
                async: false,
                dataType: "json",
                data: { ma: ma },
                success: function (result) {
                    if (result.length == 0) { // ko tồn tại                        
                        //                            alert("Xóa dữ liệu thành công.");
                        window.location.reload();
                    }
                    else {
                        alert(result);
                    }
                }
            });
        }

    }
    function DichVu_HienThi(ma) {

        $.ajax({
            type: "POST",
            url: '<%=Url.Action("HienThi") %>',
            cache: false,
            async: false,
            dataType: "json",
            data: { ma: ma },
            success: function (result) {
            }
        });
    }
</script>
    <div style="margin-bottom: 20px;">
        <p style="background-color: #348AB7; color: White; font-weight: bold; font-size: 20px;">
            Các loại dịch vụ</p>
        <table width="100%" cellpadding="2" cellspacing="0" border="0">
            <tr>
                <td>
                    <table width="100%">
                        <tr>
                            <td align="left">
                                <%= Html.ActionLink("Thêm dịch vụ", "Create",null, new { @class = "classThem" })%>
                            </td>
                            <td align="right">
                                <%: Html.ActionLink("Quay lại", "quantri", "Admin", null, new { @class = "" })%>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table id="bang_admin" class="tbl colorize" width="100%" border="0">
                        <tbody>
                            <tr>
                                <th align="center" width="20px">
                                    TT
                                </th>
                                <th>
                                    Tiêu đề
                                </th>
                                <th align="center" width="100">
                                    Hiển thị
                                </th>
                                <th align="right" width="30">
                                    Xóa
                                </th>
                            </tr>
                        </tbody>
                        <tbody>
                            <% foreach (DichVu tt in (List<DichVu>)ViewData["dichvus"])
                               {               
                            %>
                            <tr class="tb_hienthi">
                                <td align="center" valign="middle">
                                    <input type="text" disabled="disabled" style="width: 20px" autocomplete="off" class="orderbox"
                                        value="<%:tt.ThuTu %>" maxlength="4" id="thutu" />&nbsp;
                                </td>
                                <td align="left" valign="middle">
                                    <a href="<%=Url.Action("Edit","dichvu", new { id = tt.MaDV } ) %>">
                                        <%:tt.TenDV%>
                                    </a>
                                </td>
                                <td align="center">
                                    <%if (tt.HienThi == false)
                                      {
                                    %>
                                    <a href="javascript:DichVu_HienThi(<%:tt.MaDV%>);">
                                        <input type="checkbox" />
                                    </a>
                                    <%}
                                      else
                                      {%>
                                    <a href="javascript:DichVu_HienThi(<%:tt.MaDV%>);">
                                        <input type="checkbox" checked="checked" /></a>
                                    <%} %>
                                </td>
                                <td align="center">
                                    <a href="javascript:DichVu_Delete(<%:tt.MaDV %>);">
                                        <img src="../../Content/imagesAdmin/images/pic_trash.gif" alt="" /></a>
                                </td>
                            </tr>
                            <% } %>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="text-align: center; clear: both; width: 100%; padding: 20px 0 10px 0;">
                    <% if ((string)ViewData["pageLinks"] != "")
                       { %>
                    <%= ViewData["pageLinks"] %>
                    <% } %>Tổng: <strong>
                        <%= ViewData["total"]%></strong>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
